import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class FollowLoadingButton extends StatelessWidget {
  final bool? isFollow;
  final bool? isLoading;
  final bool? isCollectStyle;
  final double radius;
  final bool isDarkStyle; // 暗网模式
  const FollowLoadingButton({
    super.key,
    this.isFollow,
    this.isLoading,
    this.isCollectStyle,
    this.radius = 6,
    this.isDarkStyle = false,
  });

  @override
  Widget build(BuildContext context) {
    if (isFollow == true) {
      return Container(
        width: 70,
        height: 28,
        alignment: Alignment.center,
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(radius),
            color: Color(0x0DFFFFFF),
            // border: Border.all(color: Colors.white.withOpacity(.6), width: 1)
        ),
        child: (isLoading == true)
            ? _loadingWidget() :
        Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Icon(
              Icons.check,
              size: 14,
              color: Color(0xff989898),
            ),
            const SizedBox(width: 4),
            Text(
              isCollectStyle == true ? "收藏" : "关注",
              style: TextStyle(
                color: Color(0xff989898),
                fontSize: 12,
              ),
            ),
          ],
        ),
      );
    }
    return Container(
      width: 70,
      height: 28,
      alignment: Alignment.center,
      decoration: BoxDecoration(
          color: Color(0xffE1351F),
          borderRadius: BorderRadius.circular(radius),
          // border: Border.all(color: Color(0xff3476FF), width: 1)
      ),
      child: (isLoading == true)
          ? _loadingWidget()
          : Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Icon(
                  Icons.add,
                  size: 14,
                  color: Color(0xffffffff),
                ),
                const SizedBox(width: 4),
                Text(
                  isCollectStyle == true ? "收藏" : "关注",
                  style: TextStyle(
                    color: Color(0xffffffff),
                    fontSize: 12,
                  ),
                ),
              ],
            ),
    );
  }

  Widget _loadingWidget() {
    return const CupertinoActivityIndicator(
      color: Colors.white,
      radius: 8,
    );
  }
}
